/**
 *<p>Copyright: Copyright (c) 2012</p> 
 *<p>Company: SCPII</p>
 *<p>Project:scpii-api</p>
 *@author xiezhouyan
 *@Date 2013-3-14 上午11:22:27
 *@version 1.0
 *@description:
 */
package com.scpii.api.service.app.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.scpii.api.domain.app.AppConfigs;
import com.scpii.api.persistence.app.AppConfigsMapper;
import com.scpii.api.service.app.AppConfigsService;

@Service
public class AppConfigsServiceImpl implements AppConfigsService {

	@Resource
	private AppConfigsMapper appConfigsMapper;

	@Override
	public AppConfigs selectByAppIdAndKey(Long appId, String key) {
		return appConfigsMapper.selectByAppIdAndKey(appId, key);
	}

	@Override
	public Map<String, String> selectByKeys(Long appId, String[] keys) {
		List<AppConfigs> appConfigs = appConfigsMapper
				.selectByKeys(appId, keys);
		Map<String, String> configs = null;
		if (appConfigs != null && appConfigs.size() != 0) {
			configs = new HashMap<String, String>();
			for (AppConfigs config : appConfigs) {
				configs.put(config.getKey(), config.getValue());
			}
		}
		return configs;
	}

}
